package com.teamone.etl.admin.feign;

import com.baomidou.mybatisplus.extension.api.R;
import com.github.pagehelper.PageInfo;
import com.teamone.etl.admin.feign.fallback.EnterpriseWebServiceFallBackImpl;
import com.teamone.etl.enterprise.entity.AlarmPhone;
import com.teamone.etl.enterprise.entity.Enterprise;
import com.teamone.etl.enterprise.request.EnterpriseRequest;
import com.teamone.etl.exception.CustomException;
import java.util.List;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 @author WangZhuoRan */
@FeignClient(value = "enterprise",fallbackFactory = EnterpriseWebServiceFallBackImpl.class)
public interface EnterpriseWebService {

    /**
     Web层Feign调用Enterprise 分页查询
     @param request 请求参数封装类
     @return 分页后结果集
     @throws CustomException 自定义异常
     */
    @RequestMapping(value = "/enterprise/list",method = RequestMethod.POST)
    R<PageInfo<Enterprise>> getEnterpriseList (@RequestBody EnterpriseRequest request) throws CustomException;

    /**
     Web层Feign调用Enterprise 修改
     @param request 请求参数封装类
     @return 受影响行数
     @throws CustomException 二次校验自定义异常
     */
    @RequestMapping(value = "/enterprise/update",method = RequestMethod.PUT)
    R<Boolean> updateEnterprise (@RequestBody EnterpriseRequest request) throws CustomException ;

    /**
     Web层Feign调用Enterprise 添加
     @param request 请求参数封装类
     @param flag 判断 注册/添加
     @return 受影响行数
     @throws CustomException 二次校验自定义异常
     */
    @RequestMapping(value = "/enterprise/add/{flag}",method = RequestMethod.POST)
    R<Boolean> addEnterprise (@RequestBody EnterpriseRequest request,
                              @PathVariable(value = "flag",required = false) Integer flag) throws CustomException ;

    /**
     Web层Feign调用Enterprise 上传营业执照
     @param file 营业执照
     @return url地址
     @throws CustomException 自定义异常
     */
    @RequestMapping(value = "/enterprise/uploadLicenseImage",method = RequestMethod.POST)
    R<String> uploadLicenseImage(MultipartFile file) throws CustomException;

    /**
     Web层Feign调用Enterprise 上传企业图片/头像
     @param file 企业图片/头像
     @return url地址
     @throws CustomException 自定义异常
     */
    @PostMapping("/enterprise/uploadEnterpriseImage")
    R<String> uploadEnterpriseImage(MultipartFile file) throws CustomException;

    /**
     预警电话列表
     @param enterpriseId 企业id
     @return 预警电话列表
     @throws CustomException 自定义异常
     */
    @GetMapping("/alarmPhone/{enterpriseId}")
    R<List<AlarmPhone>> getAlarmList (@PathVariable(name = "enterpriseId") Integer enterpriseId) throws CustomException;

    /**
     添加预警电话
     @param alarmPhone 要添加的信息
     @return 成功/失败
     @throws CustomException 自定义异常
     */
    @PostMapping("/alarmPhone")
    R<Boolean> addAlarm (@RequestBody AlarmPhone alarmPhone) throws CustomException;

    /**
     删除预警电话
     @param id 要删除的数据的主键id
     @return 成功/失败
     @throws CustomException 自定义异常
     */
    @DeleteMapping("/alarmPhone/{id}")
    R<Boolean> deleteAlarm(@PathVariable(name = "id") Integer id) throws CustomException;

}
